/*
 *          TexGen.glsl
 *
 *      version : GLSL 3.1+ core
 *
 */

//------------------------------------------------------------------------------


-- Cloud.Fragment

/*
  Fragment program used to create the cloud texture
  (needs to include Noise.glsl as a fragment shader too).
  
  PostProcess.Vertex is used as vertex shader.
*/


// IN
in vec2 vTexCoord;

// OUT
layout(location=0) out vec4 fragColor;

// Noise prototypes
float normalizeNoise(float n);
float fbm_pnoise( vec2, float, const int, const float, const float);
float fbm_dpnoise( vec2, float, const int, const float, const float);
float fbm_pnoise( vec3, float, const int, const float, const float);



vec4 computeCloudTexture(vec2 v)
{
  const int octave = 8;
  const float zoom = 1.0f/256.0f; // to tile, must be a power of two
  const float freq = 2.0f;        // to tile, must be an integer
  const float w = 0.5f;
  
  // Just a really basic noise without post processing
  float noise = 1.5f*fbm_pnoise( v, zoom, octave, freq, w);

  return vec4( vec3(noise), 1.0f);
}

void main()
{
  fragColor = computeCloudTexture(gl_FragCoord.xy);
}


--

//------------------------------------------------------------------------------


-- Terrain.Fragment


// IN
in vec2 vTexCoord;

// OUT
layout(location=0) out vec4 fragColor;

// Noise prototypes
float normalizeNoise(float n);
float fbm_pnoise( vec2, float, const int, const float, const float);
float fbm_dpnoise( vec2, float, const int, const float, const float);
float fbm_pnoise( vec3, float, const int, const float, const float);

/*
vec4 computeCloudTexture(vec2 v)
{
  const int octave = 8;
  const float zoom = 1.0f/256.0f; // to tile, must be a power of two
  const float freq = 2.0f;        // to tile, must be an integer
  const float w = 0.5f;
  
  // Just a really basic noise without post processing
  float noise = 1.5f*fbm_pnoise( v, zoom, octave, freq, w);

  return vec4( vec3(noise), 1.0f);
}
*/

void main()
{
  fragColor = vec4(0.0f, 1.0f, 0.0f, 0.5f);
}



